<%@ include file = "/js/_of_js.jsp"%> 
<script>
    function goback()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/back2LastList.jsp";
    }

	function checkSelector()
	{
		for(var i = 0; i < detailForm.tags('select').length; i ++)
        {
			if(detailForm.tags('select')[i].value == "%")
            {
				detailForm.tags('select')[i].focus();
				return false
            }
        }
		return true;
	}

    function initCommon()
    {
        $('authorName').value = "";
    }

    function commonValidate()
    {
        $('knowledgePointSpan').innerHTML = "";
        $('difficultySpan').innerHTML = "";
        $('sourceSpan').innerHTML = "";
        $('authorNameSpan').innerHTML = "";
        if($('knowledgePointId').options.length == 0)
        {
            inValidated();
            $('knowledgePointSpan').innerHTML = "<font color='red'>必填</font>";
        }
        if($("difficultyId").value == "--请选择--")
        {
            inValidated();
            $('difficultySpan').innerHTML = "&nbsp;&nbsp;<font color='red'>必填</font>";
        }
        if($("sourceId").value === "--请选择--")
        {
            inValidated();
            $('sourceSpan').innerHTML = "&nbsp;&nbsp;<font color='red'>必填</font>";
        }
        if($("authorName").value == "")
        {
            inValidated();
            $('authorNameSpan').innerHTML = "&nbsp;&nbsp;<font color='red'>必填</font>";
        }
    }
    function reset4Update()
    {       
        <%
        if(examQuestion != null)
        {
            %>
             initCommon();
             delAllOptions($('knowledgePointId'));    
            <%
            for(Type kp : examQuestion.getKnowledgePoints())    
            {
                %>addOption($('knowledgePointId'),'<%= kp.getId()%>','<%= kp.getName()%>');<%
            }
            %>
            $('difficultyId').value = '<%= examQuestion.getDifficulty().getId()%>';
            $('sourceId').value = '<%= examQuestion.getSource().getId()%>';
            $('authorName').value = '<%= examQuestion.getAuthorName()%>';
            <%
        }// if
            %>
    }
</script>
<script>
    function changeFck(obj)
    {
        for(var i = 0; i < 20; i ++)
        {
            try
            {
                eval("$('fck" + i + "').style.fontWeight = '';");
                eval("$('fck" + i + "inst').style.display = 'none';");
            }
            catch(e)
            {
            }
        }
        obj.style.fontWeight = "bold";
        eval("$('" + obj.id + "inst').style.display = '';");
    }

    function ShowKnowledgePoints()
    {
        $('addKpListDiv').style.display = "none";
        $('kpListDiv').style.display = "";
    }
</script>
    <form name="detailForm" action="<%= request.getContextPath()%>/moduleinfor/Controller.jsp" method="post" >       
        <tr >           			
			<td  class="detailTD11" rowspan="4">知识点&nbsp;&nbsp;</td>
            <td class="detailTD12" rowspan="4" id="kptd">
                <table width="100%">
                    <tr>
                        <td width="40%" style="height:1.5in">
                            <div id="addKpInputDiv" >
                                <input type="input" id="addKpInput" name="addKpInput" style="width:2.5in;" of="true"  onkeyup="keyUp();nextOfFocused(this);">
                                <script type="text/javascript">
                                    function keyUp()
                                    {
                                        if(window.event.keyCode == 40) 
                                        {      
                                            try
                                            {
                                                $('knowledgePoints').options(0).selected = true;
                                                $('knowledgePoints').focus(); 	
                                            }
                                            catch (e)
                                            {
                                            }	
                                        }
                                        if(window.event.keyCode == 13)
                                        {
                                            $("addKpInput").value = "";
                                             ShowKnowledgePoints();
                                        }
                                    }

                                    function cpKps()
                                    {
                                         $("kpListDiv").style.display = "";
                                            $("addKpListDiv").style.display = "none";
                                            addSelected2OtherSelector($("knowledgePoints"),$("knowledgePointId"));
                                            $("addKpInput").value = "";
                                            ShowKnowledgePoints();
                                            $("addKpInput").focus();
                                            
                                    }
                                    function kpListKeyOp()
                                    {
                                        //alert(event.keyCode);
                                        // 回车选值
                                        if(event.keyCode == 13)
                                        {
                                            cpKps();     
                                            return;
                                        }
                                        if(event.keyCode >40 || event.keyCode < 37)
                                        {
                                            $('addKpInput').focus();
                                            return;
                                        }
                                    }
                                    new Form.Element.Observer('addKpInput', 1, 
                                            function(element, value) 
                                            {                                                    
                                                if(value == '%')
                                                {
                                                         value = "";
                                                }
                                                if(value != "")
                                                {
                                                    new Ajax.Updater('addKpListDiv', 
                                                                     '<%= request.getContextPath()%>/moduleinfor/exammanager/examquestion/findKnowledgePoints.jsp', 
                                                                     {asynchronous:true, evalScripts:true, parameters:'keyword='+value})
                                                }
                                            })
                                </script>
                            </div>                           
                            <div id="addKpListDiv" >
                                
                            </div>
                            <div id="kpListDiv">
                                <select id="knowledgePointId" name="knowledgePointId" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="false" style="width: 2.5in;height:1.5in;" multiple ></select>
                            </div>
                        </td>
                        <td  align="center">
                        <span id="knowledgePointJSSpan"></span>
                        <span id="knowledgePointSpan"></span>
                            <table >
                                <tr>
                                    <td><input type="button" value="添加" onclick="$('addKpInput').focus()"/></td>
                                </tr>
                                <tr>
                                    <td><input type="button" value="删除" onclick="delSelectedOption($('knowledgePointId'))"/></td>
                                </tr>
                                <tr>
                                    <td><input type="button" value="全删" onclick="delAllOptions($('knowledgePointId'))"/></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td class="detailTD11">难度&nbsp;&nbsp;</td>
            <td class="detailTD12" width="35%">
                <select id="difficultyId" name="difficultyId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">	
				</select><span id="difficultySpan"></span>
            </td>  
        </tr>
        <tr>
			<td class="detailTD11">来源&nbsp;&nbsp;</td>
            <td class="detailTD12" >
                <select id="sourceId" name="sourceId"  onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true">					
				</select><span id="sourceSpan"></span>
            </td>  
        </tr>
        <tr>
			<td class="detailTD11">编者&nbsp;&nbsp;</td>
            <td class="detailTD12" >
                <input type="text" id="authorName" name="authorName" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"><span id="authorNameSpan"></span>
            </td>
		</tr>
        <input type="hidden" name="questTypeId" value="<%= request.getParameter("questTypeId")%>">
        